home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209b.zip / octave-2.09 / SCRIPTS.ZIP / scripts / plot / multiplot.m < prev    next >
Text File  |  1996-11-15  |  3KB  |  121 lines

  1. ## Copyright (C) 1996 John W. Eaton
  2. ##
  3. ## This file is part of Octave.
  4. ##
  5. ## Octave is free software; you can redistribute it and/or modify it
  6. ## under the terms of the GNU General Public License as published by
  7. ## the Free Software Foundation; either version 2, or (at your option)
  8. ## any later version.
  9. ##
  10. ## Octave is distributed in the hope that it will be useful, but
  11. ## WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. ## General Public License for more details.
  14. ##
  15. ## You should have received a copy of the GNU General Public License
  16. ## along with Octave; see the file COPYING.  If not, write to the Free
  17. ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA
  18. ## 02111-1307, USA.
  19.  
  20. ## usage: multiplot (xn, yn)
  21. ##
  22. ## Sets and resets multiplot mode
  23. ##
  24. ## If multiplot(0,0) then it will close multiplot mode and and if
  25. ## arguments are non-zero, then it will set up multiplot mode with
  26. ## xn,yn subplots along x and y axes.
  27. ##
  28. ## NOTE: this will work only with gnuplot installed with
  29. ##       multiplot patch
  30.  
  31. ## Author: Vinayak Dutt, Dutt.Vinayak@mayo.EDU
  32. ## Created: 3 July 95
  33. ## Adapted-By: jwe
  34.  
  35. function multiplot (xn, yn)
  36.  
  37.   if (! gnuplot_has_multiplot)
  38.     error ("multiplot: gnuplot does not appear to support this feature");
  39.   endif
  40.  
  41.   ## global variables to keep track of multiplot options
  42.  
  43.   global multiplot_mode
  44.   global multiplot_xsize multiplot_ysize
  45.   global multiplot_xn multiplot_yn
  46.   global multiplot_xi multiplot_yi
  47.  
  48.   ## This is a real kludge.  We gnuplot should be made so that replot can
  49.   ## be executed while doing multiple plots...
  50.  
  51.   global multiplot_save_auto_replot = automatic_replot
  52.  
  53.   if (nargin != 2)
  54.     usage ("multiplot (xn, yn)");
  55.   endif
  56.  
  57.   if (! (is_scalar (xn) && is_scalar (yn)))
  58.     error ("multiplot: xn and yn have to be scalars");
  59.   endif
  60.  
  61.   if (automatic_replot)
  62.     warning ("turning off automatic replot for multiplot mode");
  63.     multiplot_save_auto_replot = automatic_replot;
  64.     automatic_replot = 0;
  65.   endif
  66.  
  67.   xn = round (xn);
  68.   yn = round (yn);
  69.  
  70.   if (xn == 0 && yn == 0)
  71.  
  72.     gset nomultiplot;
  73.     gset size 1, 1;
  74.     gset origin 0, 0;
  75.  
  76.     multiplot_mode = 0;
  77.     multiplot_xsize = 1;
  78.     multiplot_ysize = 1;
  79.     multiplot_xn = 1;
  80.     multiplot_yn = 1;
  81.     multiplot_xi = 1;
  82.     multiplot_yi = 1;
  83.  
  84.     ## Someone may have reset it betweeen calls...
  85.  
  86.     if (! isstr (automatic_replot) && ! automatic_replot)
  87.       automatic_replot = multiplot_save_auto_replot;
  88.     endif
  89.  
  90.     return;
  91.  
  92.   else
  93.  
  94.     if (xn < 1 || yn < 1)
  95.       error ("multiplot: xn and yn have to be positive integers");
  96.     endif
  97.  
  98.     gset multiplot;
  99.  
  100.     xsize = 1.0 ./ xn;
  101.     ysize = 1.0 ./ yn;
  102.  
  103.     eval (sprintf ("gset size %g, %g", xsize, ysize));
  104.  
  105.     xo = 0.0;
  106.     yo = (yn - 1.0)*ysize;
  107.  
  108.     eval (sprintf ("gset origin %g, %g", xo, yo));
  109.  
  110.     multiplot_mode = 1;
  111.     multiplot_xsize = xsize;
  112.     multiplot_ysize = ysize;
  113.     multiplot_xn = xn;
  114.     multiplot_yn = yn;
  115.     multiplot_xi = 1;
  116.     multiplot_yi = 1;
  117.  
  118.   endif
  119.  
  120. endfunction
  121.